<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.18"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>embedme: src/CppUnitLite.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">embedme
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">CppUnitLite.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>C++单元测试  
<a href="#details">More...</a></p>
<div class="textblock"><code>#include &lt;iostream&gt;</code><br />
</div>
<p><a href="_cpp_unit_lite_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_simple_string.html">libemb::SimpleString</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">简单字符串类  <a href="classlibemb_1_1_simple_string.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_failure.html">libemb::Failure</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">CppUnit错误类  <a href="classlibemb_1_1_failure.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_test_result.html">libemb::TestResult</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">CppUnit测试结果类  <a href="classlibemb_1_1_test_result.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_test.html">libemb::Test</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">CppUnit测试类  <a href="classlibemb_1_1_test.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">class &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classlibemb_1_1_test_registry.html">libemb::TestRegistry</a></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">CppUnit测试注册器类  <a href="classlibemb_1_1_test_registry.html#details">More...</a><br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a3dfa2f4df9d70d8e2082960fb913297e"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><b>TEST</b>(testName,  testGroup)</td></tr>
<tr class="separator:a3dfa2f4df9d70d8e2082960fb913297e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3e1cfef60e774a81f30eaddf26a3a274"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><b>CHECK</b>(condition)</td></tr>
<tr class="separator:a3e1cfef60e774a81f30eaddf26a3a274"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad8fa79f5d491cc01af302832785e90fe"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><b>CHECK_EQUAL</b>(expected,  actual)</td></tr>
<tr class="separator:ad8fa79f5d491cc01af302832785e90fe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7921a0c4f152a7879e78fe6fc2905590"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><b>LONGS_EQUAL</b>(expected,  actual)</td></tr>
<tr class="separator:a7921a0c4f152a7879e78fe6fc2905590"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a64bb32929e2c1f2ed5521a27e775327e"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><b>DOUBLES_EQUAL</b>(expected,  actual,  threshold)</td></tr>
<tr class="separator:a64bb32929e2c1f2ed5521a27e775327e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5b870ba9f143d10f76df4fa5aa01d58f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><b>FAIL</b>(text)</td></tr>
<tr class="separator:a5b870ba9f143d10f76df4fa5aa01d58f"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a05862ecef1402cb50e0be705790eefc0"><td class="memItemLeft" align="right" valign="top"><a id="a05862ecef1402cb50e0be705790eefc0"></a>
SimpleString&#160;</td><td class="memItemRight" valign="bottom"><b>libemb::StringFrom</b> (bool value)</td></tr>
<tr class="separator:a05862ecef1402cb50e0be705790eefc0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5390a6c0dcd6e15c612fa6244cff3f1d"><td class="memItemLeft" align="right" valign="top"><a id="a5390a6c0dcd6e15c612fa6244cff3f1d"></a>
SimpleString&#160;</td><td class="memItemRight" valign="bottom"><b>libemb::StringFrom</b> (const char *value)</td></tr>
<tr class="separator:a5390a6c0dcd6e15c612fa6244cff3f1d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a886d289c73a3266d4e276f8ee11b6ca5"><td class="memItemLeft" align="right" valign="top"><a id="a886d289c73a3266d4e276f8ee11b6ca5"></a>
SimpleString&#160;</td><td class="memItemRight" valign="bottom"><b>libemb::StringFrom</b> (long value)</td></tr>
<tr class="separator:a886d289c73a3266d4e276f8ee11b6ca5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab0a8618469539e60f6c3995ecc65d051"><td class="memItemLeft" align="right" valign="top"><a id="ab0a8618469539e60f6c3995ecc65d051"></a>
SimpleString&#160;</td><td class="memItemRight" valign="bottom"><b>libemb::StringFrom</b> (double value)</td></tr>
<tr class="separator:ab0a8618469539e60f6c3995ecc65d051"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a02c3877e1e893e3695ccad3e751bd306"><td class="memItemLeft" align="right" valign="top"><a id="a02c3877e1e893e3695ccad3e751bd306"></a>
SimpleString&#160;</td><td class="memItemRight" valign="bottom"><b>libemb::StringFrom</b> (const SimpleString &amp;value)</td></tr>
<tr class="separator:a02c3877e1e893e3695ccad3e751bd306"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a01496abd234a2254d5ee84ae755ec910"><td class="memItemLeft" align="right" valign="top"><a id="a01496abd234a2254d5ee84ae755ec910"></a>
SimpleString&#160;</td><td class="memItemRight" valign="bottom"><b>libemb::StringFrom</b> (const std::string &amp;value)</td></tr>
<tr class="separator:a01496abd234a2254d5ee84ae755ec910"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>C++单元测试 </p>
<dl class="section note"><dt>Note</dt><dd>本文件拷贝于CppUnitLite(<a href="https://github.com/smikes/CppUnitLite">https://github.com/smikes/CppUnitLite</a>)项目 <div class="fragment"><div class="line">使用说明</div>
<div class="line"><span class="preprocessor">#include &quot;<a class="code" href="_cpp_unit_lite_8h.html">CppUnitLite.h</a>&quot;</span></div>
<div class="line"><span class="keyword">class </span>Case01{</div>
<div class="line"><span class="keyword">public</span>:</div>
<div class="line"><span class="keywordtype">int</span> size() </div>
<div class="line">{</div>
<div class="line">   <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line">};</div>
<div class="line"><span class="comment">//构建测试用例testCaseCase01Test</span></div>
<div class="line">TEST(Case01, testCase)</div>
<div class="line">{</div>
<div class="line">    Stack s;</div>
<div class="line">    LONGS_EQUAL(0, s.size());</div>
<div class="line">    std::string b = <span class="stringliteral">&quot;asa&quot;</span>;</div>
<div class="line">    CHECK_EQUAL(<span class="stringliteral">&quot;asa&quot;</span>, b);</div>
<div class="line">}</div>
<div class="line"><span class="comment">//构建测试用例testCaseCase02Test</span></div>
<div class="line">TEST(Case02, testCase)</div>
<div class="line">{</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main()</div>
<div class="line">{</div>
<div class="line">    TestResult tr;</div>
<div class="line">    TestRegistry::runAllTests(tr);</div>
<div class="line">    <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
</div><!-- fragment --> </dd></dl>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a id="a3e1cfef60e774a81f30eaddf26a3a274"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3e1cfef60e774a81f30eaddf26a3a274">&#9670;&nbsp;</a></span>CHECK</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define CHECK</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">condition</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">{ \</div>
<div class="line">    if (!(condition)) \</div>
<div class="line">    { \</div>
<div class="line">        result_.addFailure(Failure(name_, __FILE__,__LINE__, #condition)); \</div>
<div class="line">        return; \</div>
<div class="line">    } \</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a id="ad8fa79f5d491cc01af302832785e90fe"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ad8fa79f5d491cc01af302832785e90fe">&#9670;&nbsp;</a></span>CHECK_EQUAL</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define CHECK_EQUAL</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">expected, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">actual&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">{ \</div>
<div class="line">    if(!((expected) == (actual))) \</div>
<div class="line">    { \</div>
<div class="line">        result_.addFailure(Failure(name_, __FILE__, __LINE__, StringFrom(expected), StringFrom(actual))); \</div>
<div class="line">    } \</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a64bb32929e2c1f2ed5521a27e775327e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a64bb32929e2c1f2ed5521a27e775327e">&#9670;&nbsp;</a></span>DOUBLES_EQUAL</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define DOUBLES_EQUAL</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">expected, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">actual, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">threshold&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">{ \</div>
<div class="line">    double actualTemp = actual; \</div>
<div class="line">    double expectedTemp = expected; \</div>
<div class="line">    if (fabs ((expectedTemp)-(actualTemp)) &gt; threshold) \</div>
<div class="line">    { \</div>
<div class="line">        result_.addFailure (Failure (name_, __FILE__, __LINE__, StringFrom((<span class="keywordtype">double</span>)expectedTemp), StringFrom((<span class="keywordtype">double</span>)actualTemp)));\</div>
<div class="line">        return;\</div>
<div class="line">    } \</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a5b870ba9f143d10f76df4fa5aa01d58f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5b870ba9f143d10f76df4fa5aa01d58f">&#9670;&nbsp;</a></span>FAIL</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define FAIL</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">text</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">{ \</div>
<div class="line">    result_.addFailure (Failure(name_, __FILE__, __LINE__,(text))); \</div>
<div class="line">    return; \</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a7921a0c4f152a7879e78fe6fc2905590"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7921a0c4f152a7879e78fe6fc2905590">&#9670;&nbsp;</a></span>LONGS_EQUAL</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define LONGS_EQUAL</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">expected, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">actual&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">{\</div>
<div class="line">    long actualTemp = actual; \</div>
<div class="line">    long expectedTemp = expected; \</div>
<div class="line">    if((expectedTemp) != (actualTemp)) \</div>
<div class="line">    { \</div>
<div class="line">        result_.addFailure (Failure (name_,__FILE__,__LINE__,StringFrom(expectedTemp),StringFrom(actualTemp))); \</div>
<div class="line">        return; \</div>
<div class="line">    } \</div>
<div class="line">}</div>
</div><!-- fragment -->
</div>
</div>
<a id="a3dfa2f4df9d70d8e2082960fb913297e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a3dfa2f4df9d70d8e2082960fb913297e">&#9670;&nbsp;</a></span>TEST</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define TEST</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">testName, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">testGroup&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line"><span class="keyword">class </span>testGroup##testName##Test : <span class="keyword">public</span> Test{\</div>
<div class="line">public: \</div>
<div class="line">testGroup##testName##Test():Test(#testName <span class="stringliteral">&quot;Test&quot;</span>){}; \</div>
<div class="line">void run (TestResult&amp; result_); \</div>
<div class="line">}; \</div>
<div class="line">testGroup##testName##Test testGroup##testName##Instance = testGroup##testName##Test(); \</div>
<div class="line">void testGroup##testName##Test::run(TestResult&amp; result_)</div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->
<div class="ttc" id="a_cpp_unit_lite_8h_html"><div class="ttname"><a href="_cpp_unit_lite_8h.html">CppUnitLite.h</a></div><div class="ttdoc">C++单元测试</div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.18
</small></address>
</body>
</html>
